<script language="javascript">
var counter = 1;
var limit = 100;
function addInput(divName,num) {ldelim}
     if (counter == limit)   {ldelim}
          alert("You have reached the limit of adding " + counter + " inputs");
     {rdelim}
     else  {ldelim}
          var newdiv = document.createElement('div');
          var param="structkey_"+String(counter);
          newdiv.innerHTML = "<br><select id='structkeyopt_"+counter+"' onchange='disabletext("+counter+");' style='width: 200px;' class='inp-form' name='structkeyopt'>{$temp_options}</select>&nbsp; <input class='inp-form' style='width: 200px;' type='text' name='structkey' id='structkey_"+counter+"' />&nbsp;<input class='inp-form' style='width: 500px;' type='text' name='structval' id='structval' /><br>";
          document.getElementById(divName).appendChild(newdiv);
          counter++;
     {rdelim}
{rdelim}
</script>
<div id="page-heading">
	<h1>{$title}</h1>
          {section name=sec3 loop=$productdet_arr}
        <h2>{$productdet_arr[sec3].title}</h2>
         <h3>{$productdet_arr[sec3].add_id}</h3>
         <br>
         <a onclick="loadPage('product/index')" href="javascript: void(0);">Back to product list</a>
          &nbsp;
           <a onclick="loadPage('product/addproduct/101000100001');" href="javascript: void(0);">Add new product</a>
          &nbsp;
         <a onclick="loadPage('product/editproduct/{$productid}');" href="javascript: void(0);">Back to prodcuct details</a>
          &nbsp;
         <a onclick="loadPage('product/addimage/{$productid}');" href="javascript: void(0);">Add product image</a>

            {/section}
</div>
<form method="post" id="myForm" action="{$formaction}">
    <div id="dynamicInput">
      {section name=sec1 loop=$struct_arr}
    <br>
       <select name="structkeyopt" id="structkeyopt_{$struct_arr[sec1].structid}" style="width: 200px;" onchange="disabletext('{$struct_arr[sec1].structid}');">
	{$temp_options}
     </select>
        <input value="{$struct_arr[sec1].structkey}" class="inp-form" style="width: 200px;" type="text" name="structkey" id="structkey_{$struct_arr[sec1].structid}" />
       <input value="{$struct_arr[sec1].structvalue}"  class="inp-form" style="width: 500px;" type="text" name="structval" id="structval" />
       <a  href="javascript: void(0);" onclick="deletestructurefield({$struct_arr[sec1].structid},{$productid});"><img src="images/icons/a-minus.gif" />Delete</a>
       <br>
     {/section}
    </div>
    <br>
    <input type="button" value="Add another field" onClick="addInput('dynamicInput',1);">
    <div>
	<td>&nbsp;<input type="hidden" name="productid" id="productid" value="{$productid}" />
        <input type="hidden" name="catid" id="productid" value="{$catid}" />
        </td>
	<td><div class="edit-icoset"><a href="javascript: void(0);" onclick="saveFeatures({$productid});"><img src="images/icons/save-2.gif" />Save</a></div>
   
        </td>
   </div>
</form>
{literal}
<script type="text/javascript">

    function disabletext(x)
        {
             var txtbox="#structkey_"+String(x);
             var dropdown="#structkeyopt_"+String(x);
             var selectedval=$(dropdown).val();
             //alert(selectedval);
             if(selectedval=='')
             {
                 $(''+txtbox+'').removeAttr("disabled")
             }
             else
             {
                 $(''+txtbox+'').attr("disabled", "disabled");
             }
        }
</script>

{/literal}